

import {  ref ,onMounted,computed } from 'vue';
// CC-- 导入pinia的两个方法
import { storeToRefs } from "pinia";
import {CStore} from '../../stores/counter'

// CC-- 解构出pinia中存储的数据
const $store = CStore()
const {locationCity,currentCityDate,cityWeatherDate} = storeToRefs($store)

export const useText = ()=> {

    const data = JSON.parse(localStorage.getItem('weather'))

const text = computed( ()=>{
    
    if(currentCityDate.value.name == '') {
        return `${locationCity.value.name}人民欢迎你❤️❤️❤️    ${locationCity.value.name}人民欢迎你🧡🧡🧡   ${locationCity.value.name}人民欢迎你💛💛💛                                                下面预报天气信息:      今天天气${data.text},平均气温${data.temp}℃,${data.windDir}${data.windScale}级,风速为${data.windSpeed}公里/小时,相对湿度为${data.humidity}%`
    }else if (currentCityDate.value.name != '' && 
    currentCityDate.value.name != locationCity.value.name) {
        return `${currentCityDate.value.name}人民欢迎你💚💚💚   ${currentCityDate.value.name}人民欢迎你💙💙💙   ${currentCityDate.value.name}人民欢迎你💜💜💜   您的当前地址与定位不一致!!!💔💔💔   您的当前地址与定位不一致!!!💔💔💔   您的当前地址与定位不一致!!!💔💔💔                                             下面预报天气信息:      今天天气${data.text},平均气温${data.temp}℃,${data.windDir}${data.windScale}级,风速为${data.windSpeed}公里/小时,相对湿度为${data.humidity}%`
    }else {
        return `${currentCityDate.value.name}人民欢迎你💚💚💚   ${currentCityDate.value.name}人民欢迎你💙💙💙   ${currentCityDate.value.name}人民欢迎你💜💜💜`
    }
})


    return {
        text
    }

}